Skip to content

Conversation

@znarfm
Copy link

@znarfm znarfm commented Aug 10, 2024

Part of #59458

Addresses:

  • pandas.Timestamp.fromordinal having SA01
  • pandas.Timestamp.fromtimestamp having PR01, SA01

Changes:

  • Added See Also section for both, and a Parameters section for Timestamp.fromtimestamp.
  • Removed both from code_checks.sh

@rhshadrach rhshadrach added Docs Timestamp pd.Timestamp and associated methods labels Aug 11, 2024
@MarcoGorelli
Copy link
Member

thanks @znarfm - could you fix up the test failures please?

_________________ test_nat_doc_strings[Timestamp.fromordinal] __________________
[gw3] linux -- Python 3.10.14 /home/runner/micromamba/envs/test/bin/python3.10

compare = (<class 'pandas._libs.tslibs.timestamps.Timestamp'>, 'fromordinal')

    @pytest.mark.parametrize(
        "compare",
        (
            _get_overlap_public_nat_methods(Timestamp, True)
            + _get_overlap_public_nat_methods(Timedelta, True)
        ),
        ids=lambda x: f"{x[0].__name__}.{x[1]}",
    )
    def test_nat_doc_strings(compare):
        # see gh-17327
        #
        # The docstrings for overlapping methods should match.
        klass, method = compare
        klass_doc = getattr(klass, method).__doc__
    
        if klass == Timestamp and method == "isoformat":
            pytest.skip(
                "Ignore differences with Timestamp.isoformat() as they're intentional"
            )
    
        if method == "to_numpy":
            # GH#44460 can return either dt64 or td64 depending on dtype,
            #  different docstring is intentional
            pytest.skip(f"different docstring for {method} is intentional")
    
        nat_doc = getattr(NaT, method).__doc__
>       assert klass_doc == nat_doc
E       AssertionError

pandas/tests/scalar/test_nat.py:335: AssertionError
________________ test_nat_doc_strings[Timestamp.fromtimestamp] _________________
[gw3] linux -- Python 3.10.14 /home/runner/micromamba/envs/test/bin/python3.10

compare = (<class 'pandas._libs.tslibs.timestamps.Timestamp'>, 'fromtimestamp')

    @pytest.mark.parametrize(
        "compare",
        (
            _get_overlap_public_nat_methods(Timestamp, True)
            + _get_overlap_public_nat_methods(Timedelta, True)
        ),
        ids=lambda x: f"{x[0].__name__}.{x[1]}",
    )
    def test_nat_doc_strings(compare):
        # see gh-17327
        #
        # The docstrings for overlapping methods should match.
        klass, method = compare
        klass_doc = getattr(klass, method).__doc__
    
        if klass == Timestamp and method == "isoformat":
            pytest.skip(
                "Ignore differences with Timestamp.isoformat() as they're intentional"
            )
    
        if method == "to_numpy":
            # GH#44460 can return either dt64 or td64 depending on dtype,
            #  different docstring is intentional
            pytest.skip(f"different docstring for {method} is intentional")
    
        nat_doc = getattr(NaT, method).__doc__
>       assert klass_doc == nat_doc
E       AssertionError

pandas/tests/scalar/test_nat.py:335: AssertionError

@znarfm
Copy link
Author

znarfm commented Aug 20, 2024

Hey sorry, was gone for a few days. I think it's already handled by another contributor.

@znarfm znarfm closed this Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Docs Timestamp pd.Timestamp and associated methods

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants